package task5_2;

class Judge {
	private String birth;
	private String phone;
	private String email;
	private String password;
	private String conPass;

	String date="\\d{4}-\\d{2}-\\d{2}";
	String phonenum="(1)+(3|5|7|8)+\\d{9}";
	String mail="\\w+@+.+(com|cn|net|gov|edu|org)";
	public Judge(){}
	public Judge(String password,String conPass,String birth,String phone,String email){
		setBirth(birth);
		setPhone(phone);
		setEmail(email);
		setPassword(password);
		setConPass(conPass);
	}
	public String getBirth() {
		if(birth==null){
			return "your birthday is wrong!";
		}else{
			return birth;
		}
	}
	public void setBirth(String birth) {
		if(birth.matches(date)){
			this.birth = birth;
		}
	}
	public String getPhone() {
		if(phone==null){
			return "your phone number is wrong!";
		}else{
			return phone;
		}
	}
	public void setPhone(String phone) {
		if(phone.matches(phonenum)){
			this.phone=phone;
		}else{
			phone=null;
		}
	}
	public String getEmail() {
		if(email==null){
			return "your email address is wrong!";
		}else{
			return email;
		}
	}
	public void setEmail(String email) {
		if(email.matches(mail)){
			this.email = email;
		}else{
			email=null;
		}	
	}
	public String getPassword() {
		if(password.equals(conPass)){
			return password;
		}else{
			return "your password is not match to confirm password,please rewrite them";
		}
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public void setConPass(String conPass) {
		this.conPass = conPass;
	}
	public boolean register(String password,String conPass,String birth,String phone,String email){
		if(password!=null&&conPass!=null&&birth!=null&&phone!=null&&email!=null){
			return true;
		}else{
			return false;
		}
	}
}
